package com.xxx.video.dynamic.adapters;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.xxx.video.R;
import com.xxx.video.commen.adapters.BaseRecycleViewAdapter;
import com.xxx.video.commen.adapters.BaseViewHolder;
import com.xxx.video.commen.utils.ResourcesUtils;
import com.xxx.video.commen.utils.StringUtils;
import com.xxx.video.dynamic.beans.FriendListBean;

import butterknife.BindView;

public class MyFriendListBottomAdapter extends BaseRecycleViewAdapter<FriendListBean.PageBean.ListBean, MyFriendListBottomAdapter.MyHolder> {

    public MyFriendListBottomAdapter(@NonNull Context context) {
        super(context);
    }

    @Override
    public MyHolder onCreateDefaultViewHolder(View view, int viewType) {
        return new MyHolder(view);
    }

    @Override
    public int getItemLayout(int viewType) {
        return R.layout.item_my_friend_list_bottom;
    }

    class MyHolder extends BaseViewHolder {
        @BindView(R.id.tv_item_my_friend_list_bottom_list_title)
        TextView tvItemMyFriendListBottomListTitle;
        @BindView(R.id.tv_item_my_friend_list_bottom_list_avatar)
        ImageView tvItemMyFriendListBottomListAvatar;
        @BindView(R.id.tv_item_my_friend_list_bottom_list_name)
        TextView tvItemMyFriendListBottomListName;
        @BindView(R.id.tv_item_my_friend_list_bottom_list_nick_name)
        TextView tvItemMyFriendListBottomListNickName;

        public MyHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void setData2View(int position) {
            tvItemMyFriendListBottomListTitle.setVisibility(View.GONE);
            if (position == 0) {
                tvItemMyFriendListBottomListTitle.setVisibility(View.VISIBLE);
            }
            FriendListBean.PageBean.ListBean listBean = getItem(position);
            /*
             * avatar
             */
            Glide.with(context).load(ResourcesUtils.getInstance().getImagePath(listBean.picUrl))
                    .apply(new RequestOptions().circleCrop()
                            .placeholder(R.drawable.icon_default_avatar)
                            .error(R.drawable.icon_default_avatar)
                    ).into(tvItemMyFriendListBottomListAvatar);
            /*
             * name
             */
            tvItemMyFriendListBottomListName.setText(StringUtils.getInstance().getNotEmptyMsg(listBean.username));
            /*
             * nick name
             */
            tvItemMyFriendListBottomListNickName.setText(StringUtils.getInstance().getNotEmptyMsg(listBean.nickName));
        }
    }
}
